Surface block-level contextual objects in TAE snippets#1160
Open
graygilmore wants to merge 2 commits intomainfrom
Open
Surface block-level contextual objects in TAE snippets#1160graygilmore wants to merge 2 commits intomainfrom
graygilmore wants to merge 2 commits intomainfrom
Conversation
c09c9c6 to
e5870d6
Compare
The contextual objects available in a Liquid file (e.g. section, block, recommendations) are currently determined solely by file path. This makes it impossible to vary behavior based on whether the project is a theme or a theme app extension. This adds an optional getModeForURI callback to TypeSystem, CompletionsProvider, and HoverProvider, and passes context.mode into the UndefinedObject check's getContextualObjects. No behavior changes yet — mode is accepted but not acted on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In a theme app extension, snippets can only be rendered from blocks/*.liquid files, so the ambient context always includes the block-level objects (section, block, recommendations, app). Previously, the completion and diagnostic systems only provided 'app' for snippets regardless of project mode, which meant developers got no autocomplete or hover for section, block, or recommendations in TAE snippet files. Now when mode is 'app', snippets get the same contextual objects as blocks. Closes #346 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e5870d6 to
f0de2f8
Compare
graygilmore
commented
Mar 23, 2026
| if (relativePath.startsWith('snippets/')) { | ||
| // In a theme app extension, snippets can only be rendered from blocks, | ||
| // so they have access to the same contextual objects as blocks. | ||
| if (mode === 'app') return BLOCK_CONTEXTUAL_OBJECTS; |
Contributor
Author
There was a problem hiding this comment.
Instead of threading mode all the way through we could do something really lazy here but the cost doesn't seem too bad and it sets up a pattern that we might want to use in other areas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In a theme app extension, snippets can only be rendered from
blocks/*.liquidfiles, so the ambient context always includes the block-level objects (section,block,recommendations,app). Previously, the completion and diagnostic systems only providedappfor snippets regardless of project mode — no autocomplete or hover forsection,block, orrecommendationsin TAE snippet files.Commit 1: Thread project mode through TypeSystem and UndefinedObject check
Adds an optional
getModeForURIcallback toTypeSystem,CompletionsProvider, andHoverProvider, and passescontext.modeinto theUndefinedObjectcheck. No behavior changes — pure plumbing so that downstream code can branch on project mode.Commit 2: Surface block-level contextual objects in TAE snippets
When mode is
app, snippets now get the same contextual objects as blocks:section,block,recommendations,app. This applies to both completions and theUndefinedObjectdiagnostic.Closes #346
🎩 Tophatting
snippets/*.liquidfile{{ section— you should now seesectionin the autocomplete suggestionsblock,recommendations, andappalso appearUndefinedObjectwarnings for these objectsapp—section,block, andrecommendationsshould NOT appear